package com.zhouyu.user.service;

import com.zhouyu.springframework.BeanPostProcessor;
import com.zhouyu.springframework.Component;

@Component
public class MyBeanPostProcessor implements BeanPostProcessor {
    /**
     * @param bean     入参Bean原值target
     * @param beanName
     * @return         返回代理对象，这个对象会赋值给生命周期初始化
     */
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) {
        //可实现Aop的功能

        //类拦截判断
        //增加代理切面（@Before）
        //返回代理对象

        System.out.println("BeanPostProcessor.postProcessAfterInitialization");
        return bean;
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) {
        //可实现@Value的功能

        System.out.println("BeanPostProcessor.postProcessBeforeInitialization");
        return bean;
    }
} 